package com.hongshan.wallet.core.wallet

import android.app.Application
import android.databinding.ObservableField
import android.view.View
import com.hongshan.wallet.R
import com.hongshan.wallet.base.MyViewModel
import com.hongshan.wallet.bean.BankCardBean
import com.hongshan.wallet.router.RouterIndex
import com.hongshan.wallet.router.go

/**
 * Copyright Zhangxx.
 * Copyright (c) 2019
 * All rights reserved
 *
 * @project  : Wallet
 * @package  : com.example.wallet.core.wallet
 * @author   : zhangxx
 * @date     : 2019/3/26
 * @email    : qq957413212@hotmail.com
 * @desc     : //TUDO
 */
class BankCardRecycleViewModel(application: Application) : MyViewModel(application) {

    val backgroundDraw = arrayOf(
        application.resources.getDrawable(R.drawable.bg_bank1),
        application.resources.getDrawable(R.drawable.bg_bank2),
        application.resources.getDrawable(R.drawable.bg_bank3)
    )

    val icon = ObservableField<String>()

    val background = ObservableField(backgroundDraw[0])

    val bankName = ObservableField("")

    val cardType = ObservableField("储蓄卡")

    val cardStatus = ObservableField("已启用")

    val cardNum = ObservableField("")

    var data: BankCardBean? = null
        set(value) {
            field = value
            bankName.set(field?.bank)
            cardNum.set(field?.card_no)
            cardType.set(field?.card_type_name)
            cardStatus.set(
                if (field?.status == 1) {
                    "已启用"
                } else {
                    "已禁用"
                }
            )
            icon.set(field?.bank_img)
        }

    val click = View.OnClickListener {
//        go(
//            RouterIndex.BIND_ACCOUNT,
//            mapOf(
//                Constant.ROUTE_PARAMS_KEY.BIND_ACCOUNT_TYPE to Constant.ROUTE_PARAMS_KEY.BIND_ACCOUNT_TYPE_BANK_CARD,
//                Constant.ROUTE_PARAMS_KEY.BIND_ACCOUNT_DATA_BANKCARD to data
//            )
//        )
    }

    val bottomClick = View.OnClickListener {
        go(RouterIndex.ADD_CARD)
    }
}